from django.contrib.auth.models import AbstractUser
from django.db import models
from mlh.utils.models import BaseModel
# Create your models here.

class User(AbstractUser):
    """用户模型类"""
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    birth = models.DateField(verbose_name='出生日期', null = True)
    city = models.CharField(verbose_name='居住城市',max_length=11)
    website = models.CharField(verbose_name='个人网站',max_length=60)
    address = models.CharField(verbose_name='通讯地址',max_length=44)
    password = models.CharField(verbose_name='密码',max_length=128)
    gender = models.BooleanField(verbose_name='性别',default = False)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
    avatar = models.ImageField(upload_to='avatar', verbose_name='封面图片')

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):

        return self.username

class EduEp(BaseModel):
    from_year = models.IntegerField(verbose_name='起始年份')
    from_month = models.IntegerField(verbose_name='起始月份')
    to_year = models.IntegerField(verbose_name='截止年份')
    to_month = models.IntegerField(verbose_name='截止月份',)
    school_name = models.CharField(verbose_name='毕业学校',max_length=11)
    edu_detail = models.CharField(verbose_name='详情描述',max_length=11)
    user_id = models.ForeignKey('User',verbose_name='用户')
    class Meta:
        db_table = 'tb_education'
        verbose_name = '教育经历'
        verbose_name_plural = verbose_name



class WorkEp(BaseModel):
    company = models.CharField(verbose_name = '公司名字',max_length=16)
    position = models.CharField(verbose_name = '职位',max_length=13)
    from_year = models.IntegerField(verbose_name = '起始年份')
    from_month = models.IntegerField(verbose_name = '起始月份')
    to_year = models.IntegerField(verbose_name = '截止年份')
    to_month = models.IntegerField(verbose_name = '截止月份')
    user_id = models.ForeignKey('User',verbose_name='用户')

    class Meta:
        db_table = 'tb_work'
        verbose_name = '工作经历'
        verbose_name_plural = verbose_name

class UserSkill(models.Model):
    user_id = models.ForeignKey('User',verbose_name='用户')
    skill_id = models.ForeignKey('Skill',verbose_name='技能')
    class Meta:
        db_table = 'tb_user_skill'
        verbose_name = '用户技术'
        verbose_name_plural = verbose_name


class Skill(models.Model):

    name = models.CharField(verbose_name='技术名字',max_length=20)
    class Meta:
        db_table = 'tb_skill'
        verbose_name = '技术'
        verbose_name_plural = verbose_name

